import * as THREE from "three";

export class Aura extends THREE.Object3D {
  private readonly _map: THREE.Texture;

  /**
   * 构造函数
   * @constructor
   */
  constructor() {
    super();

    // 几何体
    const geometry = new THREE.SphereGeometry(2.02, 40, 40);

    const loader = new THREE.TextureLoader();
    this._map = loader.load("/public/img/yuanhuan1.png");
    // this._map = loader.load("/public/img/aura3_type2.png");
    this._map.wrapS = this._map.wrapT = THREE.RepeatWrapping;

    // 材质
    const material = new THREE.MeshBasicMaterial({
      map: this._map,
      blending: THREE.AdditiveBlending,
      transparent: true,
    });

    // 创建mesh
    const mesh = new THREE.Mesh(geometry, material);
    this.add(mesh);
  }

  /**
   * 每帧更新
   */
  public update() {
    this._map.offset.x = -performance.now() / 1000 / 4;
    this._map.offset.y = -performance.now() / 1000 / 4;
  }
}
